package com.fand.manager.controller;

import javax.annotation.Resource;

import com.anji.captcha.model.common.ResponseModel;
import com.anji.captcha.model.vo.CaptchaVO;
import com.anji.captcha.service.CaptchaService;
import com.fand.common.util.ResultHelp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 图形验证码
 * <p>
 * Author: zhangjiabin
 * Email: javaboyok@163.com
 * CreateDate: 2021/6/16
 * Version: 1.0
 */
@Controller
public class FandCaptchaController {

    @Resource
    private CaptchaService captchaService;

    @PostMapping("/verify")
    @ResponseBody
    public ResultHelp verify(CaptchaVO captchaVO){
        ResponseModel response = captchaService.verification(captchaVO);
        if(!response.isSuccess()){
            //验证码校验失败，返回信息告诉前端
            //repCode  0000  无异常，代表成功
            //repCode  9999  服务器内部异常
            //repCode  0011  参数不能为空
            //repCode  6110  验证码已失效，请重新获取
            //repCode  6111  验证失败
            //repCode  6112  获取验证码失败,请联系管理员
            //repCode  6113  底图未初始化成功，请检查路径
            //repCode  6201  get接口请求次数超限，请稍后再试!
            //repCode  6206  无效请求，请重新获取验证码
            //repCode  6202  接口验证失败数过多，请稍后再试
            //repCode  6204  check接口请求次数超限，请稍后再试!
            return ResultHelp.error(response.getRepMsg(),Integer.valueOf(response.getRepCode()));
        }
        return ResultHelp.success();
    }
}
